package com.example.twotwo_project;

import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;

public class Board_ViewAc extends ActionBarActivity {
	
	String id;
	Board_DB db;
	Data data;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.board_activity_view);
		
		ActionBar actionBar = getSupportActionBar();
	    actionBar.setDisplayHomeAsUpEnabled(true);
	}


	@Override
	protected void onResume() {
		super.onResume();
		TextView mdate = (TextView)findViewById(R.id.textView1);
		TextView subject = (TextView)findViewById(R.id.textView2);
		TextView content = (TextView)findViewById(R.id.textView3);
		
		db = new Board_DB(this, "note", null, 1);
		db.getReadableDatabase();
		
		id = getIntent().getExtras().getString("id");
		// Toast.makeText(getApplicationContext(), id, Toast.LENGTH_SHORT).show();
		data = db.select(id);
		
		mdate.setText(data.mdate);
		subject.setText(data.subject);
		content.setText(data.content);
	}
	


	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {


    	switch(item.getItemId()){
		case android.R.id.home:
			finish();
			return true;
		}
		
    	return super.onOptionsItemSelected(item);
	}
}
